import plugin from '../../../lib/plugins/plugin.js'
import { segment } from 'oicq'
export class getNaXiDa extends plugin {
  constructor() {
    super({
      /** 功能名称 */
      name: '纳西妲',
      /** 功能描述 */
      dsc: '拿一张纳西妲的自拍',
      /** https://oicqjs.github.io/oicq/#events */
      event: 'message',
      /** 优先级，数字越小等级越高 */
      priority: 999,
      rule: [
        {
          /** 命令正则匹配 */
          reg: '^#(纳西妲)',
          /** 执行方法 */
          fnc: 'mySelfie',
        },
        {
          reg: '.*',
          fnc: 'replyALL'
        }
      ],
    })
  }

  async replyALL () {
    if (this.e.atBot) {
      this.e.reply('就算你艾特纳西妲,纳西妲也不清楚哦 (* ^ *)')
    }
  }

  /**
   *
   * @param e oicq传递的事件参数e
   */
  async mySelfie (e) {
    const { msg } = e
    const regexField = (regex, text) => {
      if (regex.test(text) === true) {
        return text
      } else {
        return
      }
    }
    switch (msg.slice(4)) {
      case '来我床上':
        {
          e.reply('纳西妲在洗白白~，请稍等...')
        }
        break
      case regexField(/^(吻|亲)我$/, msg.slice(4)):
        {
          e.reply('嗯嘛 > v <...')
        }
        break
      case '的自拍':
        {
          let imageList = [
            100379252, 100156765, 100296962, 100185998, 100079529, 100134085,
            100107814, 100097748, 100214067, 100223068, 99851343, 100296886,
            99627475, 99478089
          ]
          let colorimage = segment.image(`https://px2.rainchan.win/img/regular/${imageList[Math.floor(Math.random() * imageList.length)]}`)
          e.reply(colorimage)
        }
        break
      default:
        {
          e.reply('哼')
        }
        break
    }
  }

}
